package com.song.ioc;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Description: 实现这个接口，可以插手spring的初始化过程。
 * 这里是更改了userServiceTwoImpl的创建属性，从单例改成了原型
 * @author: songzhangyong
 * @Date: 2019/11/5 11:55
 */

//@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
//		BeanDefinition userServiceTwoImpl = beanFactory.getBeanDefinition("userServiceTwoImpl");
//		userServiceTwoImpl.setScope("prototype");
		System.out.println("MyBeanFactoryPostProcessor 的 postProcessBeanFactory 调用-------");
	}

}
